package com.lagou.controller;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.naming.factory.BeanFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Calendar;

@Controller
@Slf4j
@RequestMapping("/login")
public class LoginController {

    /**
     * 获取并封装当前年份跳转到登录页login.html
     */
    @RequestMapping("/toLoginPage")
    public String toLoginPage(Model model) {
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    @RequestMapping("/home")
    public String login(@RequestBody JSONObject jsonObject) {
        log.info(jsonObject.toJSONString());
        return "home";
    }
}
